//同步载入css,js
function ajaxLoad(id,url,type){   //type: js:javascript   css:css
    var  xmlHttp = null;
    if(window.ActiveXObject)//IE
    {
        try {
            //IE6以及以后版本中可以使用
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            //IE5.5以及以后版本可以使用
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    else if(window.XMLHttpRequest)//Firefox，Opera 8.0+，Safari，Chrome
    {
        xmlHttp = new XMLHttpRequest();
    }
    //采用同步加载
    xmlHttp.open("GET",url,false);
    //发送同步请求，如果浏览器为Chrome或Opera，必须发布后才能运行，不然会报错
    xmlHttp.send(null);
    //4代表数据发送完毕
    if ( xmlHttp.readyState == 4 )
    {
        //0为访问的本地，200到300代表访问服务器成功，304代表没做修改访问的是缓存
        if((xmlHttp.status >= 200 && xmlHttp.status <300) || xmlHttp.status == 0 || xmlHttp.status == 304)
        {
        	if(type=='js')
        	{
            var myHead = document.getElementsByTagName("HEAD").item(0);
            var myScript = document.createElement( "script" );
            //myScript.language = "javascript";
            //myScript.type = "text/javascript";
            //myScript.src=url
            myScript.id = id;
            try{
                //IE8以及以下不支持这种方式，需要通过text属性来设置
                myScript.appendChild(document.createTextNode(xmlHttp.responseText));
            }
            catch (ex){
                myScript.text = xmlHttp.responseText;
            }
            myHead.appendChild( myScript );
            return true;
          }
        	else{
        		var myHead = document.getElementsByTagName("HEAD").item(0);
            var myCss = document.createElement( "style" );
            myCss.id = id;
            try{
                //IE8以及以下不支持这种方式，需要通过text属性来设置
                myCss.appendChild(document.createTextNode(xmlHttp.responseText));
            }
            catch (ex){
                myCss.text = xmlHttp.responseText;
            }
            myHead.appendChild( myCss );
            return true;
          }
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}

//if(sessionStorage.load==null){
//	sessionStorage.load='0'
//}
var dynamicLoading = {
    css: function(path){
		if(!path || path.length === 0){
			throw new Error('argument "path" is required !');
		}
		var head = document.getElementsByTagName('head')[0];
        var link = document.createElement('link');
        link.href = path;
        link.rel = 'stylesheet';
        link.type = 'text/css';
        head.appendChild(link);
    },
    js: function(path){
		if(!path || path.length === 0){
			throw new Error('argument "path" is required !');
		}
		var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.src = path;
        script.type = 'text/javascript';
        head.appendChild(script);
    }
}

dynamicLoading.css('css/light7.css')
dynamicLoading.css('css/mobiscroll.css')
dynamicLoading.css('css/swiper-3.3.1.min.css')
dynamicLoading.css('css/layout.css')



//ajaxLoad("css_1", "css/light7.css",'css');
//ajaxLoad("css_3", "css/layout.css",'css');
//ajaxLoad("css_2", "css/mobiscroll.css",'css');
//ajaxLoad("css_4", "css/swiper-3.3.1.min.css",'css');


ajaxLoad("js_1", "js/jquery_2.1.4_min.js",'js');
ajaxLoad("js_2", "js/crypto-js.js",'js');
ajaxLoad("js_3", "js/light7.js",'js');
ajaxLoad("js_4", "js/my_class/my.js",'js');
ajaxLoad("js_5", "js/mobiscroll.js",'js');
ajaxLoad("js_6", "js/swiper-3.3.1.jquery.min.js",'js');





